package com.ucomm.talent.adapter;

import java.util.ArrayList;

import com.ucomm.talent.R;
import com.ucomm.talent.adapter.JobOffersListAdapter.ViewHolder;
import com.ucomm.talent.model.JobFairInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class JobFairInfoListAdapter extends BaseAdapter{
	
	private LayoutInflater mInflater;
	private ArrayList<JobFairInfo> mData;
	
	public JobFairInfoListAdapter(Context context,ArrayList<JobFairInfo> mData) {
		super();
		this.mInflater = LayoutInflater.from(context);
		this.mData = mData;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mData.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mData.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
	        if (convertView == null) {

	            holder=new ViewHolder();

	            convertView = mInflater.inflate(R.layout.job_fair_item_layout, null);
	            holder.title = (TextView) convertView.findViewById(R.id.title);//招聘会名称
	            holder.fair_id = (TextView)convertView.findViewById(R.id.fair_id);//招聘会id
	            holder.organizers = (TextView)convertView.findViewById(R.id.organizers);//举办方
	            holder.fair_address = (TextView) convertView.findViewById(R.id.fair_address);//招聘会地址
	            convertView.setTag(holder);

	        }else {
	            holder = (ViewHolder)convertView.getTag();
	        }
	        JobFairInfo info = mData.get(position);
	        holder.title.setText(info.getTitle());
	        holder.fair_id.setText(info.getJobFairId()+"");
	        holder.organizers.setText(info.getOrganizers());
	        holder.fair_address.setText(info.getAddress());

	        return convertView;
	}
	 final class ViewHolder{
		public TextView title;
		public TextView fair_id;
        public TextView organizers;
        public TextView fair_address;
		}
	public ArrayList<JobFairInfo> getmData() {
		// TODO Auto-generated method stub
		return mData;
	}
	

}
